<?php 
$categoryConfig = Configure::read('category');
?>
<ul class="list course clearfix" id="courseJoined">
	<?php foreach ($courses as $course):?>
	<li>
		<h3 class="courseTitle"><?php echo $this->Html->link($course['Course']['title'], array('controller' => 'course', 'action' => 'view', $course['Course']['id']), array());?></h3>
		<a class="image" href="<?php echo $this->Html->url(array('controller' => 'course', 'action' => 'view', $course['Course']['id']), array());?>">
			<?php echo $this->Html->image($course['Course']['course_image01'] ? Configure::read('Course.upload_path_prefix').$course['Course']['course_image01'] : 'demoCourse.jpg', array('alt' => ''));?>
			<?php if (isset($categoryConfig[$category[$course['Course']['category']]]['image'])):?>
			<?php echo $this->Html->image($categoryConfig[$category[$course['Course']['category']]]['image'], array('border' => '0', 'alt' => '', 'class' => 'category'));?>
			<?php else:?>
			<?php echo $this->Html->image('icon_01.png', array('border' => '0', 'alt' => '', 'class' => 'category'));?>
			<?php endif;?>
		</a>
		<?php if ($avatar = $course['Profiles']['icon_image']):?>
			<?php
			echo $this->Html->link(
				$this->Html->image(Configure::read('User.upload_path_prefix') . $avatar, array('alt' => '', 'width' => 44, 'height' => 44)),
				array('controller' => 'profile', 'action' => 'view', $course['Course']['user_id']),
				array('class' => 'teacherAvatar', 'escape' => false)
			);
			?>
		<?php else:?>
		<?php
		echo $this->Html->link(
			$this->Html->image('icon.jpg', array('alt' => '', 'width' => 44, 'height' => 44)),
			array('controller' => 'profile', 'action' => 'view', $course['Course']['user_id']),
			array('class' => 'teacherAvatar', 'escape' => false)
		);
		?>
		<?php endif;?>
		<dl class="detail">
			<dd>日時:</dd>
			<dt>
				<?php if(strtotime($course['CoursesDetail']['opening_date']) == FALSE){
					echo "未定";
				}else{
					echo $this->Time->format('Y.m.d H:i', $course['CoursesDetail']['opening_date']);
				}
				?>
			</dt>
			<dd>場所:</dd>
			<dt><?php echo $course['CoursesDetail']['area'] ? $areas[$course['CoursesDetail']['area']] : '</br>' ;?></dt>
			<dd>講師:</dd>
			<dt><a href="<?php echo $this->Html->url(array('controller' => 'profile', 'action' => 'view', $course['Course']['user_id']));?>">
				<?php echo $this->User->getUsername($course);?>
			</a></dt>
		</dl>
		<p class="description"><?php echo $course['Course']['description'];?></p>
	</li>
	<?php endforeach;?>
</ul>
<?php echo $this->element('paginator'); ?>